﻿using Amazon.SimpleNotificationService;
using Amazon.SimpleNotificationService.Model;
using NUnit.Framework;
using Rhino.Mocks;
using ShuttleBus.Transports.AmazonSqs.Clients;


namespace Tests.Transports.AmazonSqs.SnsWrapperTests
{
    public partial class SnsWrapperTests
    {
        [TestFixture]
        public class WhenCreatingTopics
        {
            private AmazonSimpleNotificationService _sns;
            private SnsWrapper _wrapper;

            [SetUp]
            public void SetUp()
            {
                _sns = MockRepository.GenerateMock<AmazonSimpleNotificationService>();
                _wrapper = new SnsWrapper(_sns);
            }

            [TearDown]
            public void TearDown()
            {
                _sns.VerifyAllExpectations();
            }

            [Test]
            public void Creates_Topic()
            {
                var topicArn = "the topic arn";
                var topicName = "topic name";

                var response = new CreateTopicResponse
                                   {
                                       CreateTopicResult = new CreateTopicResult
                                                               {
                                                                   TopicArn = topicArn
                                                               }
                                   };
                _sns.Expect(s => s.CreateTopic(Arg<CreateTopicRequest>.Matches(m => m.Name == topicName))).Return(response);

                var result = _wrapper.Create(topicName);

                Assert.AreEqual(topicArn, result.TopicArn);
            }
        }
    }
}